<?php

class Book extends Article {

	var $id_book;
	var $title;
	var $description;
	
	var $authors;
	/////////////////////////////////////////////////
	// Static member methods
	
	function Book($id_book = -1, $complete = false) {
		global $site;
		$this->_table_name = "articles";
		$this->_site = $site;
		$this->_object_type = "book";
		$this->_db = new mysqlconn(HOST,USER,PASS,DB);
		$this->_meta_fields = array();
		$this->authors = array();
		$this->_alias_fields = array("id_article" => "id_book", "title" => "title", "content" => "description");

		if ($id_book != -1) {
			$this->load($id_book);
		}
	}
	
	function create($title, $description) {
		$book = new Book();
		$book->title = $title;
		$book->description = $description;		
		return $book->save();
	}

	//////////////////////////////////////////////////////////////////////////////
	// Instance member methods
	
	function get_authors() {
		return $this->get_membresies_by_type("author");
	}
	
	function count_authors() {
		$authors = $this->get_authors();
		return count($authors);
	}
	
	function get_genres() {
		return $this->get_membresies_by_type("genre");
	}
	
	///////////////////////////////////////////////////////////////////////////////
	// Polymorphism methods
	function get_instance($id_instance) {
		return new Book($id_instance);
	}
		
}

?>